import request from '@/utils/request'

export function login(data) {
  return request({
    url: process.env.VUE_APP_ADMIN_API + '/front/login',
    method: 'post',
    data: data
  })
}

export function getInfo(token) {
  return request({
    url: process.env.VUE_APP_ADMIN_API + '/front/userInfo',
    method: 'get',
    params: { token }
  })
}
// 校验用户角色是否有admin权限
export function validateRole(roles) {
  if(roles && roles.length > 0){
    for(let role of roles){
      if(role.startsWith("admin"))
        return true;
    }
  }
  return false
}

export function logout() {
  return request({
    url: process.env.VUE_APP_ADMIN_API + '/auth/logout',
    method: 'post'
  })
}

export function getMenu() {
  return request({
    url: process.env.VUE_APP_ADMIN_API + '/front/getMenu',
    method: 'get',
  })
}
